bgo #721407 - Fix scrolled window to work with template subclasses.
authorTristan Van Berkom <tristan@upstairslabs.com>
Sat, 4 Jan 2014 02:55:41 +0000 (11:55 +0900)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 5 Jan 2014 01:36:17 +0000 (20:36 -0500)
Ensure the hscrollbar & vscrollbar at gtk_scrolled_window_add() time,
this allows one to subclass GtkScrolledWindow with templates and add
children, as this will happen at instance initialization time before
the construct adjustment properties take effect.

gtk/gtkscrolledwindow.c

index 56cf66296835a218203e46fc51b8c0e3c9d9a6bb..e17376e844b38bcef4288030e4dd313cc708b23b 100644 (file)
@@ -2926,6 +2926,15 @@ gtk_scrolled_window_add (GtkContainer *container,
   scrolled_window = GTK_SCROLLED_WINDOW (container);
   priv = scrolled_window->priv;
 
+  /* gtk_scrolled_window_set_[hv]adjustment have the side-effect
+   * of creating the scrollbars
+   */
+  if (!priv->hscrollbar)
+    gtk_scrolled_window_set_hadjustment (scrolled_window, NULL);
+
+  if (!priv->vscrollbar)
+    gtk_scrolled_window_set_vadjustment (scrolled_window, NULL);
+
   hadj = gtk_range_get_adjustment (GTK_RANGE (priv->hscrollbar));
   vadj = gtk_range_get_adjustment (GTK_RANGE (priv->vscrollbar));